<?php

class TournamentController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
    	$validators = array('id' => array('Int'));
	    $input = new Zend_Filter_Input(null, $validators);
	    $input->setData($this->getRequest()->getParams());
	    if($input->isValid()){
	    	/*	Hard to use findDependentRowset
	    	 * for display ALL events becouse of
	    	 * fetchAll return RowsetAbstract != TableRow
	    	 * 
	    	 * $tournament = new Application_Model_DbTable_Tournament();
			$res = $tournament->GetTournamentById($input->id);
			$this->view->events = $res->findDependentRowset('Application_Model_DbTable_Event', 'Tournament')->toArray();
			*/
	    	$events = new Application_Model_DbTable_Event();
	    	$this->view->events = $events->GetEvents($input->id);
	    }
	    else{
	    	throw new Zend_Controller_Action_Exception('Invalid input');
	    }
		
    }
}